#include <cstdio>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
typedef __gnu_pbds::priority_queue<int,less<int>,__gnu_pbds::pairing_heap_tag> pq;
int read(){
	char c=getchar();int x=0;
	while(c<48||c>57) c=getchar();
	do x=x*10+(c^48),c=getchar();
	while(c>=48&&c<=57);
	return x;
}
const int N=100003;
int hd[N],ver[N<<1],nxt[N<<1],tot;
void add(int u,int v){nxt[++tot]=hd[u];hd[u]=tot;ver[tot]=v;}
int n;
pq rt[N];
void dfs(int u,int fa){
	for(int i=hd[u];i;i=nxt[i]){
		int v=ver[i];
		if(v==fa) continue;
		dfs(v,u);
		rt[u].join(rt[v]);
	}
	if(rt[u].size()>1){
		int x=rt[u].top();rt[u].pop();
		int y=rt[u].top();rt[u].pop();
		if((~x&1)&&(~y&1)){
			--y;
			rt[u].push(1);
		}
		rt[u].push(x+y+1);
	}
	else if(!rt[u].empty()){
		int x=rt[u].top();rt[u].pop();
		rt[u].push(x+1);
	}
	else rt[u].push(1);
}
int main(){
	freopen("bird.in","r",stdin);
	freopen("bird.out","w",stdout);
	n=read();
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	dfs(1,0);
	printf("%d\n",rt[1].top());
	return 0;
}
